<template>
  <div class="father">
    <h3>父组件</h3>
    <div class="content">
      <Category>
        <template v-slot:s2>
          <ul>
            <li v-for="g in games" :key="g.id">{{ g.play }}</li>
          </ul>
        </template>

        <template v-slot:s1>
          <h2>热门游戏列表</h2>
        </template>
      </Category>

      <Category>

        <template #s2>
          <img :src="imgUrl" alt="">
        </template>

        <template #s1>
          <h2>热门游戏列表</h2>
        </template>
      </Category>

      <!-- v-slot只能写在组件或者是template标签上，这里#s2 相当于是v-slot:s2 -->
      <Category>

        <template #s2>
          <video :src="videoUrl" controls></video>
        </template>

        <template #s1>
          <h2>今日影视推荐</h2>
        </template>
      </Category>
    </div>
  </div>
</template>

<script setup lang="ts" name="Father">
import Category from './Category.vue'
import { reactive, ref } from 'vue';

let games = reactive([
  {
    id: 'diwhauda01', play: '英雄联盟'
  },
  {
    id: 'diwhauda02', play: '王者荣耀',
  },
  {
    id: 'diwhauda03', play: '穿越火线',
  }
])

let imgUrl = ref("https://z1.ax1x.com/2023/11/19/piNxLo4.jpg")
let videoUrl = ref("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")


</script>

<style scoped>
.father {
  background-color: rgb(165, 164, 164);
  padding: 20px;
  border-radius: 10px;
}

.content {
  display: flex;
  justify-content: space-evenly;
}

img,
video {
  width: 100%;
}

h2 {
  background-color: orange;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
}
</style>